package com.mzx.javase.常用类;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Description: BigDecimal使用测试
 * @Date: 2022/6/21 10:25
 * @Author: MarKing
 */
public class BigDecimalTest01 {
    public static void main(String[] args) {
        double d1 = 1.0;
        double d2 = 0.9;
        System.out.println(d1-d2);
        double d3 = 1.5;
        double d4 = 0.6;
        System.out.println((d3 - d2) / d4);

        BigDecimal b1 = new BigDecimal("1.0");
        BigDecimal b2 = new BigDecimal("0.9");
        BigDecimal add = b1.add(b2);
        System.out.println("（b1+b2）add的值："+ add);
        BigDecimal subtract = b1.subtract(b2);
        System.out.println("（b1-b2）add的值："+ subtract);
        BigDecimal multiply = b1.multiply(b2);
        System.out.println("b1*b2="+multiply);
        BigDecimal divide = b1.divide(b2,2, BigDecimal.ROUND_HALF_UP);
        System.out.println("b1/b2="+divide);

    }
}
